#!/bin/bash

# update source code

TOP_DIR=$(pwd)

if [ ! -d $TOP_DIR/source ] ; then
	mkdir $TOP_DIR/source || exit 0
	echo "create directory source"
fi

cd $TOP_DIR/source

# <1> binutils
if [ ! -d binutils ] ; then
	cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils
	mv src binutils
else
	cd binutils
	cvs -z 9 up
	cd ..
	echo "binutils updated"
fi

# <2> gcc
if [ ! -d gcc ] ; then
	svn co svn://gcc.gnu.org/svn/gcc/trunk gcc
	# svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-4_4-branch gcc
else
	cd gcc
	svn up
	cd ..
	echo "gcc updated"
fi

# <3> gdb
if [ ! -d gdb ] ; then
	cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co gdb
	mv src gdb
else
	cd gdb
	cvs -z 9 up
	cd ..
	echo "gdb updated"
fi

# <4> mingw-w64
if [ ! -d mingw-w64 ] ; then
	svn co https://mingw-w64.svn.sourceforge.net/svnroot/mingw-w64/trunk mingw-w64
else
	cd mingw-w64
	svn up
	cd ..
	echo "mingw-w64 updated"
fi

# <5> gmp
if [ ! -d gmp-5.0.0 ] ; then
	wget http://ftp.gnu.org/gnu/gmp/gmp-5.0.0.tar.bz2
	tar xjf gmp-5.0.0.tar.bz2
fi

# <6> mpfr
if [ ! -d mpfr-2.4.2 ] ; then
	wget http://www.mpfr.org/mpfr-current/mpfr-2.4.2.tar.bz2
	tar xjf mpfr-2.4.2.tar.bz2
fi

# <7> MPC
if [ ! -d mpc-0.8.1 ] ; then
	wget http://www.multiprecision.org/mpc/download/mpc-0.8.1.tar.gz
	tar xzf mpc-0.8.1.tar.gz
fi

